package file;

import java.io.File;
import java.io.IOException;
public class FileAg {
    public static void main(String[] args) throws IOException {
        extracted();
        File f1 = new File("D:\\develop\\程序\\JAVAFourDimension-master\\JAVAFourDimension\\src\\demo_file\\aaa");
        System.out.println(haveAvi(f1));
    }
    //添加文件

    public static void extracted() throws IOException {
        File f1 = new File("D:\\develop\\程序\\JAVAFourDimension-master\\JAVAFourDimension\\src\\demo_file\\aaa");
        f1.mkdirs();
        File f2 = new File(f1, "a.txt");
        if (f2.createNewFile()) {
            System.out.println("添加成功！！！");
        } else {
            System.out.println("添加失败！！！");
        }
    }

    //判断文件是否存在
    public static boolean haveAvi(File file) {
        File[] files = file.listFiles();
        for (File file1 : files) {
            if (file1.isFile() && file1.getName().endsWith(".avi")) {
                return true;
            } else {
                System.out.println("无");
                return false;
            }
        }
        return false;
    }
}
